using Cinemachine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour
{
    CinemachineVirtualCamera virtualCamera;
    CinemachineConfiner confiner;
    public float scrollSpeed = 0.1f;
    public float maxOrthoSize = 7f;
    public float minOrthoSize = 1f;

    // Start is called before the first frame update
    void Start()
    {
        virtualCamera = GetComponent<CinemachineVirtualCamera>();
        confiner = GetComponent<CinemachineConfiner>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.LeftAlt))
        {
            virtualCamera.m_Lens.OrthographicSize
                = Mathf.Clamp(virtualCamera.m_Lens.OrthographicSize + Input.mouseScrollDelta.y * scrollSpeed,
                minOrthoSize,
                maxOrthoSize);
        }
    }

    public void ChangeConfiner(Collider2D confiner)
    {
        this.confiner.m_BoundingShape2D = confiner;
    }
}
